import pythoncom, pyHook 

def OnEvent(event):
    # called when mouse events are received
    print 'MessageName:',event.MessageName
    print 'Message:',event.Message
##    print 'Time:',event.Time
##    print 'Window:',event.Window
##    print 'WindowName:',event.WindowName
##    print 'Position:',event.Position
##    print 'Wheel:',event.Wheel
##    print 'Injected:',event.Injected
    if event.MessageName == "key down":
        print 'Key:', event.Key 
    print '---'

# return True to pass the event to other handlers
    return True

# create a hook manager
hm = pyHook.HookManager()
# watch for all mouse events
hm.MouseAll = OnEvent
# set the hook
hm.HookMouse()

#hook keyboard

hm.KeyDown = OnEvent
# set the hook
hm.HookKeyboard()

# wait forever
pythoncom.PumpMessages()


